package com.xzq.constans;

import com.xzq.message.Message;
import com.xzq.serializer.Serializer;
import com.xzq.serializer.SerializerUtil;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author xzq
 * @Description //协议支持类
 * @Date 2021/11/22 20:54
 * @Version 1.0.0
 **/
public class ProtocolSupport {
    //RPC协议默认魔数
    public static int magicNum = 0x63;
    //RPC协议默认版本
    public static int defaultVersion = 1;
    //RPC协议默认序列化方案
    public static int defaultSerializer = Serializer.PROTOBUF;
    //RPC协议支持的版本
    public static Set<Integer> versions = new HashSet<>();

    static {
        versions.add(1);
    }

    public static boolean isSupport(int magicNum, int version, Serializer serialize, Class<? extends Message> clazz) {
        if (magicNum == ProtocolSupport.magicNum &&
                versions.contains(version) &&
                serialize != null &&
                clazz != null)
        {
            return true;
        }
        return false;
    }
}
